home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7499 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  70 lines

  1. Path: cliffy.lfwc.lockheed.com!news
  2. From: James Bassett <bassett@flash.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: memory leak problems
  5. Date: 23 Feb 1996 16:48:55 GMT
  6. Organization: Computer Science Corp.
  7. Message-ID: <4gkr5n$dc2@cliffy.lfwc.lockheed.com>
  8. NNTP-Posting-Host: 11200855.-pcimport.lfwc.lockheed.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  13.  
  14. I am using Visual C++ 1.51 under Windows 3.1. Using an ODBC recordset and 
  15. creating an instance of the set using the _new_ operator and then 
  16. deleting the object with the _delete_ operator. But we lose the same 
  17. amount of memory each time. Anyone know how to recover the lost memory or 
  18. what are we doing wrong? 
  19.  
  20. Below is an example:
  21.  
  22. /////////////////////////////////////////////////////////////////////////
  23. ////
  24. // CPlotDefset recordset
  25.  
  26. class CPlotDefset : public CRecordset
  27. {  
  28.  
  29. public:
  30.     CPlotDefset(CDatabase* pDatabase = NULL); 
  31.     
  32.  
  33. In another .h file a pointer is declared:
  34.  
  35. //
  36. //                                   
  37.     CPlotDefset    *plotdef_set;    //Plot defintion set    
  38.  
  39.  
  40. Then in a dialog box routine the following is done:
  41.  
  42. //
  43. //
  44.     plotdef_set = new CPlotDefset;   //Get an instance of plot 
  45. definition set    
  46.  
  47.     plotdef_set->Open();            //Open the database set
  48.     
  49. //    
  50.     
  51.     CPlotEx dlg;    //Dialog for existing plots
  52.     
  53.     if(dlg.DoModal() == IDOK) 
  54.     {    
  55.         plotdef_set->Close();
  56.         delete plotdef_set;        //delete the plot 
  57. defintion set
  58.         
  59.         Invalidate();
  60.     }
  61. }
  62.                            
  63. After doing the delete plotdef_set not all of the memory is released.
  64.  
  65.                  I hope someone can help!!
  66.  
  67.                 Jim Bassett
  68.                 bassett@flash.net
  69.  
  70.